package pattern.behavioral.memento.simple;

/**
 * @author: chaoyang.ren  
 * @date:Jun 16, 2017  
 * @time:3:30:24 PM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class Game {
	private HeroState heroState;

	public HeroState getHeroState() {
		return heroState;
	}

	public void setHeroState(HeroState heroState) {
		this.heroState = heroState;
	}
	/**
     * 备份游戏
     */
    public GameMemento createMemento(){
        return new GameMemento(this);
    }
    
    /**
     * 玩游戏
     * @throws InterruptedException 
     */
    public void play(){
    	heroState.setHealthPoint(0);
    	heroState.setMagicPoint(0);
    }
    
    /**
     * 游戏还原
     */
    public void restore(GameMemento memento){
        this.heroState = memento.getGame().getHeroState();
    }
}

